package com.ruoyi.web.controller.gas;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gas.domain.GasCarNum;
import com.ruoyi.gas.service.IGasCarNumService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * Controller
 * 
 * @author morris
 * @date 2023-12-08
 */
@Api("车牌号码信息")
@RestController
@RequestMapping("/gas/carNum")
public class GasCarNumController extends BaseController
{
    @Autowired
    private IGasCarNumService gasCarNumService;

    /**
     * 查询列表
     */
    @PreAuthorize("@ss.hasPermi('gas:carNum:list')")
    @GetMapping("/list")
    public TableDataInfo list(GasCarNum gasCarNum)
    {
        startPage();
        List<GasCarNum> list = gasCarNumService.selectGasCarNumList(gasCarNum);
        return getDataTable(list);
    }

    /**
     * 导出列表
     */
    @PreAuthorize("@ss.hasPermi('gas:carNum:export')")
    @Log(title = "", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GasCarNum gasCarNum)
    {
        List<GasCarNum> list = gasCarNumService.selectGasCarNumList(gasCarNum);
        ExcelUtil<GasCarNum> util = new ExcelUtil<GasCarNum>(GasCarNum.class);
        util.exportExcel(response, list, "数据");
    }

    /**
     * 获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('gas:carNum:query')")
    @GetMapping(value = "/{carId}")
    public AjaxResult getInfo(@PathVariable("carId") Long carId)
    {
        return success(gasCarNumService.selectGasCarNumByCarId(carId));
    }

    /**
     * 新增
     */
    @PreAuthorize("@ss.hasPermi('gas:carNum:add')")
    @Log(title = "", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GasCarNum gasCarNum)
    {
        return toAjax(gasCarNumService.insertGasCarNum(gasCarNum));
    }

    /**
     * 修改
     */
    @PreAuthorize("@ss.hasPermi('gas:carNum:edit')")
    @Log(title = "", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GasCarNum gasCarNum)
    {
        return toAjax(gasCarNumService.updateGasCarNum(gasCarNum));
    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('gas:carNum:remove')")
    @Log(title = "", businessType = BusinessType.DELETE)
	@DeleteMapping("/{carIds}")
    public AjaxResult remove(@PathVariable Long[] carIds)
    {
        return toAjax(gasCarNumService.deleteGasCarNumByCarIds(carIds));
    }
}
